-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for save_method PATCH #483
add support for save_method PATCH #483
Conversation
✅ Deploy Preview for opal-docs canceled.
|
I think this can go together with the full docs for this feature as a section in the data-updates tutorial and perhaps a quick reference in the data-sources article |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @thilak009,
Seems like a very solid PR to me, Well done!
Had one or two comments/question - please fix/reply and we'll go on to merge that.
I liked your solution to OpaClient's data cache. Unfortunately we don't have unit tests for it - have you tried (manually) testing the backup feature? (OFFLINE_MODE).
Thank you! your contribution is much appreciated
yep, i checked the updates in the JSON file manually when |
also as Or Weis mentioned, adding this comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work @thilak009 !
Changes proposed
Add support for
PATCH
as asave_method
, currently onlyPUT
is supported as asave_method
JSONPatchAction
to validate and read JSON patch operationspatch_policy_data
to opal_client which does a PATCH API call to OPAset_policy_data
orpatch_policy_data
respectivelycustom_encoder
for using it as the default encoder for doingjson.dumps
on the Union typeJsonableValue
to ignore default fields values and dump based on alias nameCheck List (Check all the applicable boxes)
Note to reviewers
Need thoughts/help on if there is a better way to do
custom_encoder
implementation, haven't used pydantic beforethe reason i used it was because FastAPI does by default print response using JSON alias names but we are not returning response from FastAPI server but rather feeding the model directly to OPA in which case the field name would be used when doing a
json.dumps
instead of alias nameand also to remove default
None
value populated fields from the dumped JSON for any request that matches theJSONPatchAction
typeOne more thing is, OPA does not support
move
operation as a JSON patch operation, refer discussion and hence OPAL would also not support itwhat would be a good place in the docs to mentions this as a NOTE ?